package cn.itcast.web.servlet;

import cn.itcast.service.UserService;
import cn.itcast.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/updatecommentsServlet")
public class UpdatecommentsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String tup=request.getParameter("tup");
        String text=request.getParameter("text");
        String comment=request.getParameter("comment");
        String userid=request.getParameter("userid");
        String purid=request.getParameter("purMid");
        String xin=request.getParameter("xin");
        if (tup==null&&tup.equals("")){
            tup="";
        }

        UserService service=new UserServiceImpl();
        int number= service.updatecomment(tup,text,comment,userid,purid,xin);
        if (number==1){

            response.getWriter().append("true");
        }else {
            response.getWriter().append("false");
        }
    }
}
